
#include <BPainter>

#include "MainWindow.h"

MainWindow::MainWindow()
{
	_accountEdit = new BLineEdit(this);
	_accountEdit->setRect(10, 32, 200, 32);

	_passwordEdit = new BLineEdit(this);
	_passwordEdit->setRect(10, 100, 200, 32);

	_ok = new BButton("login", this);
	_ok->setRect(10, 148, 48, 32);
	
	_cancel = new BButton("cancle", this);
	_cancel->setRect(200, 148, 48, 32);

	this->setMargins(3, 3, 23, 3);

	_socket = new BTcpSocket();
	_socket->bind("192.168.60.1", 2000);
	_socket->connect("192.168.60.1", 1989);
}
MainWindow::~MainWindow()
{

}

void MainWindow::recv(BObject* object, int signal, const BValue& value)
{
	if(object == _ok)
	{
		const BString text = _accountEdit->text();
		_socket->send(text.cstr(), text.size());
	}
}

void MainWindow::updateEvent(const BEvent& event)
{
	BMainWindow::updateEvent(event);
}


